package com.github.sbb.sherry.primitives.config.datasource;

import com.github.sbb.sherry.common.base.Preconditions;
import com.github.sbb.sherry.common.base.ValidateResult;


/**
 * Http数据源
 */
public class HttpDataSourceConfig implements DataSourceConfig {

    private int maximumPoolSize = 5;
    private int keepAliveDuration = 300;

    @Override
    public ValidateResult validate() {
        try {
            Preconditions.checkRange(maximumPoolSize, 3, 20, "maxIdleConnections 建议在 3 - 20 之间");
            Preconditions.checkRange(keepAliveDuration, 5, 600, "keepAliveDuration 建议在 10 - 600 之间");
        } catch (Exception e) {
            return new ValidateResult(false, e.getMessage());
        }
        return new ValidateResult(true, null);
    }

    public int getMaximumPoolSize() {
        return maximumPoolSize;
    }

    public void setMaximumPoolSize(int maximumPoolSize) {
        this.maximumPoolSize = maximumPoolSize;
    }

    public int getKeepAliveDuration() {
        return keepAliveDuration;
    }

    public void setKeepAliveDuration(int keepAliveDuration) {
        this.keepAliveDuration = keepAliveDuration;
    }
}
